#!/bin/sh

. /etc/profile

cd /tmp
TOMCAT_HOME="/u01/tomcat/"
TMP_FILE=/tmp/monit_tomcat.$$
if curl --max-time 5 -s http://127.0.0.1:80/live.jsp | grep true || curl --max-time 5 -s http://127.0.0.1:80/live.jsp | grep true || curl --max-time 5 -s http://127.0.0.1:80/live.jsp | grep true >/dev/null
 then
            echo "tomcat is ok"
 else
                pkill -9 -f "$TOMCAT_HOME"


       ${TOMCAT_HOME}bin/startup.sh
       TIME=$(date)
       echo "$TIME     tomcat has bin restart" >>/var/log/monit_tomcat.log

fi